/**
 * @Project TMHSC
 * @Author Tran Manh Hung
 * @Email: hungtmit@gmail.com | tmh@xwebgate.com
 * @Copyright © 2011 TMH. All rights reserved
 * @Createdate Feb 25, 2011
 * @Createtime 1:51:14 PM
 */

package com.tmh.study.aS3DP.mcv.minimalist
{
	import flash.display.Sprite;
	import flash.events.Event;

	public class Main extends Sprite
	{
		public function Main()
		{
			super();

			this.example2();
		}

		private function example1():void
		{
			var model:IModel = new Model();
			var controller:IKeyboardInputHandler = new Controller(model);
			var view:View = new View(model, controller, this.stage);
		}

		private function example2():void
		{
			var model:IModel = new Model();
			var controller:IKeyboardInputHandler = new Controller(model);

			// composite view
			var rootView:CompositeView = new RootNodeView(model, controller, this.stage);

			// add child leaf view
			rootView.add(new CharCodeLeafView(model));
			rootView.add(new AsciiCharLeafView(model));

			// register view to receive notification from model
			model.addEventListener(Event.CHANGE, rootView.update);
		}
	}
}